﻿using System.Drawing;
using PlusPlusPaint.Layers.VisualObjects;

namespace PlusPlusPaint.Tools
{
    class StraightLineTool : RectangleShapedObjectCreationTool
    {
        protected override void UpdatePreview(Point begin, Point end)
        {
            Layer.Invoke<LineSegment>((o) =>
            {
                o.ResizeToBeIn(begin, end);
            });
            using (Pen p = new Pen(this.Colour, this.BrushSize))
                Graphics.FromImage(Preview).DrawLine(p, begin, end);
        }

        protected override void Complete()
        {
            Layer.Invoke<LineSegment>((o) =>
            {
                o.Colour = this.Colour;
                o.BrushSize = this.BrushSize;
            });
        }
    }
}
